<!DOCTYPE html>
<html>
<head>
    <title>RC Circuit Diagram</title>
</head>
<body>
<canvas id="rcCircuitCanvas" width="500" height="300" style="border:1px solid #000;"></canvas>
<script>
    const canvas = document.getElementById('rcCircuitCanvas');
    const ctx = canvas.getContext('2d');

    // --- Style and Configuration ---
    ctx.lineWidth = 2;
    ctx.strokeStyle = 'black';
    ctx.fillStyle = 'black';
    ctx.font = 'bold 20px Arial';
    ctx.textAlign = 'center';
    ctx.textBaseline = 'bottom';

    // --- Layout Coordinates ---
    const y_top = 80;
    const y_bottom = 220;
    const x_left_wire = 50;
    const x_right_wire = 450;

    // --- Draw Components and Labels ---

    // 1. Capacitor (C)
    const cap_x_start = 120;
    const cap_x_end = 140;
    const cap_plate_h = 40;
    ctx.beginPath();
    // Plates
    ctx.moveTo(cap_x_start, y_top - cap_plate_h / 2);
    ctx.lineTo(cap_x_start, y_top + cap_plate_h / 2);
    ctx.moveTo(cap_x_end, y_top - cap_plate_h / 2);
    ctx.lineTo(cap_x_end, y_top + cap_plate_h / 2);
    ctx.stroke();
    // Label
    ctx.fillText('C = 5.0 F', cap_x_start + 10, y_top - 30);

    // 2. Resistor (R)
    const res_x_start = 220;
    const res_x_end = 320;
    const res_y = y_top;
    const res_h = 15;
    ctx.beginPath();
    ctx.moveTo(res_x_start, res_y);
    ctx.lineTo(res_x_start + 10, res_y);
    ctx.lineTo(res_x_start + 25, res_y + res_h);
    ctx.lineTo(res_x_start + 45, res_y - res_h);
    ctx.lineTo(res_x_start + 65, res_y + res_h);
    ctx.lineTo(res_x_start + 85, res_y - res_h);
    ctx.lineTo(res_x_start + 90, res_y);
    ctx.lineTo(res_x_end, res_y);
    ctx.stroke();
    // Label (Omega symbol: \u03A9)
    ctx.fillText('R = 10.0 \u03A9', (res_x_start + res_x_end) / 2, y_top - 30);

    // 3. Switch (S)
    const sw_left_x = 120;
    const sw_right_x = 180; // The other contact point
    ctx.beginPath();
    // Switch arm (open)
    ctx.moveTo(sw_left_x, y_bottom);
    ctx.lineTo(sw_right_x - 10, y_bottom - 25);
    ctx.stroke();
    // Label
    ctx.fillText('S', (sw_left_x + sw_right_x) / 2, y_bottom);

    // 4. Battery (ξ)
    const bat_x_start = 320;
    const bat_x_end = 340;
    const bat_short_h = 24;
    const bat_long_h = 40;
    ctx.beginPath();
    // Short plate (negative, on the left)
    ctx.moveTo(bat_x_start, y_bottom - bat_short_h / 2);
    ctx.lineTo(bat_x_start, y_bottom + bat_short_h / 2);
    // Long plate (positive, on the right)
    ctx.moveTo(bat_x_end, y_bottom - bat_long_h / 2);
    ctx.lineTo(bat_x_end, y_bottom + bat_long_h / 2);
    ctx.stroke();
    // Label (xi symbol: \u03BE)
    ctx.fillText('\u03BE = 12 v', (bat_x_start + bat_x_end) / 2, y_bottom + 40);


    // --- Draw Connecting Wires ---
    ctx.beginPath();
    // Top wire
    ctx.moveTo(cap_x_end, y_top);
    ctx.lineTo(res_x_start, y_top);
    // Left wire
    ctx.moveTo(x_left_wire, y_bottom);
    ctx.lineTo(x_left_wire, y_top);
    ctx.lineTo(cap_x_start, y_top);
    // Right wire
    ctx.moveTo(res_x_end, y_top);
    ctx.lineTo(x_right_wire, y_top);
    ctx.lineTo(x_right_wire, y_bottom);
    ctx.lineTo(bat_x_end, y_bottom);
    // Bottom wire
    ctx.moveTo(x_left_wire, y_bottom);
    ctx.lineTo(sw_left_x, y_bottom); // To switch
    ctx.moveTo(sw_right_x, y_bottom); // From switch (open gap)
    ctx.lineTo(bat_x_start, y_bottom); // To battery
    ctx.stroke();

</script>
</body>
</html>